﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GA.Server.ApiInfo;
using System.Xml;

namespace GA.Server.Api
{
    public class ApiInfoCharacterSkills : SignedApiCall
    {
        public IEnumerable<ApiSkill> Skills { get; private set; }

        public ApiInfoCharacterSkills()
        {
        }

        public ApiInfoCharacterSkills(int clientId, string authorizationText, string sessionId)
            : base(clientId, authorizationText, sessionId)
        {
        }

        public void LoadApi(int characterId)
        {
            LoadSignedApiCall(string.Format("characterId={0}", characterId));

            XmlNodeList skillNodes = XmlDocument.GetElementsByTagName("a:stats_character_skillsResult");
            List<ApiSkill> skills = new List<ApiSkill>();
            foreach (XmlNode skillNode in skillNodes)
            {
                skills.Add(new ApiSkill(skillNode.CreateNavigator().ReadSubtree()));
            }
            Skills = skills;
        }

        protected override string ApiCallName
        {
            get { return "CharacterSkills"; }
        }
    }
}
